//
//  FDOprationTableVIew.m
//  FamousDoctorOnline
//
//  Created by 刘胤辰 on 16/7/7.
//  Copyright © 2016年 wszyxc. All rights reserved.
//

#import "FDOprationTableVIew.h"
#import "FDBaseViewVC.h"
#import "FDOperationVC.h"

@interface FDOprationTableVIew()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)NSArray *array;

@end

@implementation FDOprationTableVIew

-(NSArray *)array{
    
    if (_array==nil) {
        
        _array=@[@"手术治疗",@"药物治疗",@"保守治疗"];
    }
    
    return _array;
}

-(instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    
   self= [super initWithFrame:frame style:style];
    
    self.delegate=self;
    self.dataSource=self;
    
    return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.array.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID=@"cellIDOperation";
    
    UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    
    cell.textLabel.text=self.array[indexPath.row];
    
    return cell;
}

//获取当前tableView的ViewController
-(FDOperationVC *)viewController{
    
    for (UIView *next=[self superview]; next; next=next.superview) {
        
        UIResponder *nextRE=[next nextResponder];
        if ([nextRE isKindOfClass:[UIViewController class]]) {
            
            return (FDOperationVC *)nextRE;
        }
    }
    return nil;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    FDOperationVC *VC1=[self viewController];
    
    NSArray * arrayVCS = VC1.navigationController.viewControllers;
    FDBaseViewVC *vc=(FDBaseViewVC *)arrayVCS[1];
    vc.labelStr3=self.array[indexPath.row];
    
    [VC1.navigationController popViewControllerAnimated:YES];
}


@end
